<?php
//代理商列表
namespace app\common\logic;

/**
 * 验证类
 *
 * */
class Check
{
    /**
     *验证手机格式
     *@author linjunbin
     */
    public static function checkPhone($phone) {
        $pattern = "/1[34578]{1}\d{9}$/";
        return preg_match($pattern, $phone);
    }
    /**
     *验证邮箱格式
     * @author linjunbin
     */
    public static function check_mail($email) {
        return preg_match("/^[\w\-\.]+@[\w\-]+(\.\w+)+$/", $email);
    }

    /**
     *  检查qq号码
     */
    public static function check_qq($qq = ''){
        return preg_match("/^[1-9](\d){4,20}$/", $qq);
    }

    /**
     *  检查身份证号码
     */
    public static function check_id_card($id_card = ''){
        return ( preg_match("/^\d{17}(\d|x)$/i", $id_card) || preg_match("/^\d{15}$/i", $id_card) );
    }

    /**
     *  检查日期 xxxx-xx-xx
     */
    public static function check_date($date = ''){
        return preg_match('/^[\d]{4}\-[\d]{1,2}-[\d]{1,2}$/', $date);
    }
    /**
     *检查日期格式XXXX-XX
     *
     */
    public static function check_month($data = '') {
        return preg_match('/^[\d]{4}\-[\d]{1,2}$/', $data);
    }
    /**
     *  检查电话号码
     */
    public static function check_telephone($telephone = ''){
        return preg_match( "/^[\d]+[\d-]*[\d]$/", $telephone);
    }
    /**
     *  检查邮政编码
     */
    public static function check_postal_code($postal_code = ''){
        return preg_match("/[1-9]{1}(\d+){5}/", $postal_code);
    }

}